package br.com.vti.sisp_sicrim.antigo.controller.relatorios;

import java.io.FileNotFoundException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import net.sf.jasperreports.engine.JRException;
import br.com.caelum.vraptor.Result;
import br.com.vti.sisp_sicrim.antigo.model.DidCadastro;
import br.com.vti.sisp_sicrim.antigo.model.Idclc001;
import br.com.vti.sisp_sicrim.antigo.model.SicControle;
import br.com.vti.sisp_sicrim.antigo.model.Sisldat8;
import br.com.vti.sisp_sicrim.antigo.model.Sisll001;
import br.com.vti.sisp_sicrim.antigo.model.Tablele;
import br.com.vti.sisp_sicrim.antigo.util.Relatorios;
import br.com.vti.sisp_sicrim.antigo.util.Sessao;

/**
 * Classe responsavel por encapsular o tratamento e as consistencias da tela
 * Idcpc003Report
 * 
 * @author Incode - Data: mai/2014
 * 
 */
public class Idcpc003Report {
	private String nomeClasse;
	private String nome;
	private String cabecaCet;
	private int dtini;
	private int dtfim;
	private int dataCorrente;
	private Long dinideRegger; // DB
	private Integer dinideNumpos; // DB
	private Long dinideNumpro; // DB
	private String diaidePoldir; // DB
	private String diaideInddir; // DB
	private String diaideMeddir; // DB
	private String diaideAnudir; // DB
	private String diaideMindir; // DB
	private String diaidePolesq; // DB
	private String diaideIndesq; // DB
	private String diaideMedesq; // DB
	private String diaideAnuesq; // DB
	private String diaideMinesq; // DB
	public int datini;
	public int datfim;
	private String nroPagina;
	private String horaCorrente;
	private Result result;
	private Sessao sessao;
	private Relatorios report;
	// Classes views
	DidCadastro vwDidcad = new DidCadastro();
	SicControle vwDvecon = new SicControle();
	// Classes includes
	Idclc001 idclc001 = new Idclc001();
	Sisldat8 sisldat8 = new Sisldat8();
	Sisll001 sisll001 = new Sisll001();
	Tablele tablele = new Tablele();

	public Idcpc003Report() throws JRException, ParseException {
		inicializar();
	}

	public Idcpc003Report(Sessao sessao) throws JRException, ParseException {
		this.sessao = sessao;
		inicializar();
	}

	public void inicializar() throws JRException, ParseException {
		report = new Relatorios();
		nomeClasse = this.getClass().getSimpleName();
		nome = "";
		dtini = 0;
		dtfim = 0;
		dataCorrente = 0;
		report.setNumeroRel(1, "C");
		{
			report.setNumeroLinhaRel(1, 1);
			{
				report.adicionaCampo(1, 1, "lit_1_1", "C", "", " ");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(2, 3);
			{
				report.adicionaCampo(1, 70, "Cabecacet", "X", "", "");
				report.adicionaCampo(119, 7, "lit_119_7", "C", "", "PAGINA:");
				report.adicionaCampo(127, 5, "nroPagina", "S", "ZZZ.ZZ9", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(3, 3);
			{
				report.adicionaCampo(1, 58, "lit_1_58", "C", "", "SISTEMA DE INFORMACOES DE SEGURANCA PUBLICA - INSTITUTO DE");
				report.adicionaCampo(60, 25, "lit_60_25", "C", "", "IDENTIFICACAO CIVIL - IDE");
				report.adicionaCampo(119, 14, "lit_119_14", "C", "", "REL.  IDCPC003");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(4, 7);
			{
				report.adicionaCampo(1, 49, "lit_1_49", "C", "", "RELACAO DAS ATUALIZACOES EFETUADAS NO CADASTRO DE");
				report.adicionaCampo(51, 13, "lit_51_13", "C", "", "ID. CIVIL DE ");
				report.adicionaCampo(70, 8, "Dtini", "N", "99/99/9999", "");
				report.adicionaCampo(85, 3, "lit_85_3", "C", "", "ATE");
				report.adicionaCampo(90, 8, "Dtfim", "N", "99/99/9999", "");
				report.adicionaCampo(115, 5, "lit_115_5", "C", "", "DATA:");
				report.adicionaCampo(121, 8, "dataCorrente", "N", "99/99/9999", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(5, 1);
			{
				report.adicionaCampo(1, 1, "lit_1_1", "C", "", "-");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(6, 7);
			{
				report.adicionaCampo(1, 7, "lit_1_7", "C", "", "R.GERAL");
				report.adicionaCampo(16, 4, "lit_16_4", "C", "", "POST");
				report.adicionaCampo(21, 7, "lit_21_7", "C", "", "PROTOC.");
				report.adicionaCampo(30, 14, "lit_30_14", "C", "", "NOME DA PESSOA");
				report.adicionaCampo(65, 12, "lit_65_12", "C", "", "IDENTIFICADA");
				report.adicionaCampo(90, 19, "lit_90_19", "C", "", "FORMATO MAO DIREITA");
				report.adicionaCampo(110, 20, "lit_110_20", "C", "", "FORMATO MAO ESQUERDA");
				report.setFimLinhaRel();
			}
		}
		report.setNumeroRel(2, "D");
		{
			report.setNumeroLinhaRel(1, 14);
			{
				report.adicionaCampo(1, 13, "Dinideregger", "N", "ZZZZZZZZ9999-9", "");
				report.adicionaCampo(16, 3, "Dinidenumpos", "N", "", "");
				report.adicionaCampo(21, 9, "Dinidenumpro", "N", "99999999", "");
				report.adicionaCampo(30, 30, "Nome", "X", "", "");
				report.adicionaCampo(65, 7, "Diaidepoldir", "X", "", "");
				report.adicionaCampo(73, 7, "Diaideinddir", "X", "", "");
				report.adicionaCampo(81, 7, "Diaidemeddir", "X", "", "");
				report.adicionaCampo(89, 7, "Diaideanudir", "X", "", "");
				report.adicionaCampo(98, 7, "Diaidemindir", "X", "", "");
				report.adicionaCampo(106, 7, "Diaidepolesq", "X", "", "");
				report.adicionaCampo(114, 7, "Diaideindesq", "X", "", "");
				report.adicionaCampo(122, 7, "Diaidemedesq", "X", "", "");
				report.adicionaCampo(130, 7, "Diaideanuesq", "X", "", "");
				report.adicionaCampo(138, 7, "Diaideminesq", "X", "", "");
				report.setFimLinhaRel();
			}
		}
		cabecaCet = "SECRETARIA DE ESTADO DA SEGURAN�A PUBLICA";
		horaCorrente = new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()); // *TIMX
		setCabecacet(cabecaCet);
		setHoraCorrente(horaCorrente);
	}

	public boolean validar() {
		// validar os campos recebidos da tela
		return true;
	}

	public String getNomeClasse() {
		return nomeClasse;
	}

	public void setNomeClasse(String nomeClasse) throws ParseException {
		this.nomeClasse = nomeClasse;
		report.adicionaValorReport("Program", nomeClasse);
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) throws ParseException {
		this.nome = nome;
		report.adicionaValorReport("Nome", nome);
	}

	public String getCabecacet() {
		return cabecaCet;
	}

	public void setCabecacet(String cabecaCet) throws ParseException {
		this.cabecaCet = cabecaCet;
		report.adicionaValorReport("Cabecacet", cabecaCet);
	}

	public int getDtini() {
		return dtini;
	}

	public void setDtini(int dtini) throws ParseException {
		this.dtini = dtini;
		report.adicionaValorReport("Dtini", dtini);
	}

	public int getDtfim() {
		return dtfim;
	}

	public void setDtfim(int dtfim) throws ParseException {
		this.dtfim = dtfim;
		report.adicionaValorReport("Dtfim", dtfim);
	}

	public int getDataCorrente() {
		return dataCorrente;
	}

	public void setDataCorrente(int dataCorrente) throws ParseException {
		this.dataCorrente = dataCorrente;
		report.adicionaValorReport("dataCorrente", dataCorrente);
	}

	public String getNroPagina() {
		return nroPagina;
	}

	public void setNroPagina(String nroPagina) throws ParseException {
		this.nroPagina = nroPagina;
		report.adicionaValorReport("nroPagina", nroPagina);
	}

	public String getHoraCorrente() {
		return horaCorrente;
	}

	public void setHoraCorrente(String horaCorrente) throws ParseException {
		this.horaCorrente = horaCorrente;
		report.adicionaValorReport("horaCorrente", horaCorrente);
	}

	public void setPageSize(int pagesize) throws JRException {
		report.setPageSize(pagesize);
	}

	public void setLineSize(int linesize) {
		report.setLineSize(linesize);
	}

	public int getPageSize() {
		return report.getPageSize();
	}

	public int getPageLine() {
		return report.getPageLine();
	}

	public void saltaLinhas(int qtdLinhas) throws ParseException, JRException {
		report.saltaLinhas(qtdLinhas);
	}

	public void gravaRelatorio(int nroRel) throws ParseException, JRException {
		setNroPagina(String.valueOf(report.getPageNumber()));
		report.gravaRelatorio(report, nroRel, false);
	}

	public void imprimir() throws FileNotFoundException, JRException {
		report.imprimir();
	}

	public Long getDinideRegger() {
		return dinideRegger;
	}

	public void setDinideRegger(Long dinideRegger) throws ParseException {
		this.dinideRegger = dinideRegger;
		report.adicionaValorReport("dinideRegger", dinideRegger);
	}

	public Integer getDinideNumpos() {
		return dinideNumpos;
	}

	public void setDinideNumpos(Integer dinideNumpos) throws ParseException {
		this.dinideNumpos = dinideNumpos;
		report.adicionaValorReport("dinideNumpos", dinideNumpos);
	}

	public Long getDinideNumpro() {
		return dinideNumpro;
	}

	public void setDinideNumpro(Long dinideNumpro) throws ParseException {
		this.dinideNumpro = dinideNumpro;
		report.adicionaValorReport("dinideNumpro", dinideNumpro);
	}

	public String getDiaidePoldir() {
		return diaidePoldir;
	}

	public void setDiaidePoldir(String diaidePoldir) throws ParseException {
		this.diaidePoldir = diaidePoldir;
		report.adicionaValorReport("diaidePoldir", diaidePoldir);
	}

	public String getDiaideInddir() {
		return diaideInddir;
	}

	public void setDiaideInddir(String diaideInddir) throws ParseException {
		this.diaideInddir = diaideInddir;
		report.adicionaValorReport("diaideInddir", diaideInddir);
	}

	public String getDiaideMeddir() {
		return diaideMeddir;
	}

	public void setDiaideMeddir(String diaideMeddir) throws ParseException {
		this.diaideMeddir = diaideMeddir;
		report.adicionaValorReport("diaideMeddir", diaideMeddir);
	}

	public String getDiaideAnudir() {
		return diaideAnudir;
	}

	public void setDiaideAnudir(String diaideAnudir) throws ParseException {
		this.diaideAnudir = diaideAnudir;
		report.adicionaValorReport("diaideAnudir", diaideAnudir);
	}

	public String getDiaideMindir() {
		return diaideMindir;
	}

	public void setDiaideMindir(String diaideMindir) throws ParseException {
		this.diaideMindir = diaideMindir;
		report.adicionaValorReport("diaideMindir", diaideMindir);
	}

	public String getDiaidePolesq() {
		return diaidePolesq;
	}

	public void setDiaidePolesq(String diaidePolesq) throws ParseException {
		this.diaidePolesq = diaidePolesq;
		report.adicionaValorReport("diaidePolesq", diaidePolesq);
	}

	public String getDiaideIndesq() {
		return diaideIndesq;
	}

	public void setDiaideIndesq(String diaideIndesq) throws ParseException {
		this.diaideIndesq = diaideIndesq;
		report.adicionaValorReport("diaideIndesq", diaideIndesq);
	}

	public String getDiaideMedesq() {
		return diaideMedesq;
	}

	public void setDiaideMedesq(String diaideMedesq) throws ParseException {
		this.diaideMedesq = diaideMedesq;
		report.adicionaValorReport("diaideMedesq", diaideMedesq);
	}

	public String getDiaideAnuesq() {
		return diaideAnuesq;
	}

	public void setDiaideAnuesq(String diaideAnuesq) throws ParseException {
		this.diaideAnuesq = diaideAnuesq;
		report.adicionaValorReport("diaideAnuesq", diaideAnuesq);
	}

	public String getDiaideMinesq() {
		return diaideMinesq;
	}

	public void setDiaideMinesq(String diaideMinesq) throws ParseException {
		this.diaideMinesq = diaideMinesq;
		report.adicionaValorReport("diaideMinesq", diaideMinesq);
	}

	public int getDatfim() {
		return datfim;
	}

	public void setDatfim(int datfim) throws ParseException {
		this.datfim = datfim;
		report.adicionaValorReport("Datfim", datfim);
	}

	public int getDatini() {
		return datini;
	}

	public void setDatini(int datini) throws ParseException {
		this.datini = datini;
		report.adicionaValorReport("Datini", datini);
	}

}
